<template>
  <div class="bg">
    <!-- 头部 -->
    <Header title="运维管理—供货管理"></Header>
    <!-- 搜索栏 -->
    <section class="search_bar">
      <LInput label="供应商名称" v-model="name"></LInput>
      <LButton label="查询数据" style="margin-left: 16px"></LButton>
      <LButton label="＋新增" style="margin-left: 16px" @click="repairDialog = true"></LButton>
    </section>
    <!-- 表格 -->
    <el-table :data="tableData1" style="width: 100%" border>
      <el-table-column prop="a" label="供应商编号" width="180" />
      <el-table-column prop="b" label="供应商名称" width="180" />
      <el-table-column prop="c" label="联系人" />
      <el-table-column prop="d" label="电话" />
      <el-table-column prop="e" label="传真" />
      <el-table-column prop="f" label="电子邮件" />
      <el-table-column prop="g" label="发票名称" />
      <el-table-column label="操作" width="150">
        <template #default>
          <el-button type="primary" size="mini" @click="repairDialog1 = true">编辑</el-button>
          <el-button type="danger" size="mini" @click="del">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 弹出框：新增 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog" title="添加供应商信息" width="40%" @close="repairDialogClose">
        <el-form label-width="110px" :model="repairForm" ref="repairFormRef" :rules="repairFormRules">
          <div class="row-1">
            <el-form-item label="供应商编号" prop="a" style="width:100%">
              <el-input v-model="repairForm.a"></el-input>
            </el-form-item>
            <el-form-item label="供应商名称" prop="b" style="width:100%">
              <el-input v-model="repairForm.b"></el-input>
            </el-form-item>
          </div>
          <div class="row-1">
            <el-form-item label="联系人" prop="c" style="width:100%">
              <el-input v-model="repairForm.c"></el-input>
            </el-form-item>
            <el-form-item label="电话" prop="d" style="width:100%">
              <el-input v-model="repairForm.d"></el-input>
            </el-form-item>
          </div>
          <div class="row-1">
            <el-form-item label="传真" prop="e" style="width:100%">
              <el-input v-model="repairForm.e"></el-input>
            </el-form-item>
            <el-form-item label="电子邮件" prop="f" style="width:100%">
              <el-input v-model="repairForm.f"></el-input>
            </el-form-item>
          </div>
          <div class="row-1">
            <el-form-item label="发票名称" prop="g" style="width:100%">
              <el-input v-model="repairForm.g"></el-input>
            </el-form-item>
            <el-form-item label="纳税人识别号" prop="h" style="width:100%">
              <el-input v-model="repairForm.h"></el-input>
            </el-form-item>
          </div>
          <div class="row-1">
            <el-form-item label="供货商地址" prop="i" style="width:100%">
              <el-input v-model="repairForm.i"></el-input>
            </el-form-item>
          </div>
          <div style="padding: 0 2vw 0 0">
            <el-form-item label="备注" prop="k" style="width:100%">
              <el-input v-model="repairForm.k" type="textarea"></el-input>
            </el-form-item>
          </div>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="primary" size="mini" @click="repairSureBtn">确定</el-button>
            <el-button type="info" size="mini" @click="repairDialog = false">取消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>
    <!-- 弹出框：编辑 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog1" title="修改供应商信息" width="40%" @close="repairDialog1Close(row)" :rules="repairForm1Rules">
        <el-form ref="repairForm1Ref" :model="repairForm1" label-width="110px" size="small">
          <div class="row-1">
            <el-form-item label="供应商编号" prop="a" style="width:100%">
              <el-input v-model="repairForm1.a" disabled></el-input>
            </el-form-item>
            <el-form-item label="供应商名称" prop="b" style="width:100%">
              <el-input v-model="repairForm1.b"></el-input>
            </el-form-item>
          </div>
          <div class="row-1">
            <el-form-item label="联系人" prop="c" style="width:100%">
              <el-input v-model="repairForm1.c"></el-input>
            </el-form-item>
            <el-form-item label="电话" prop="d" style="width:100%">
              <el-input v-model="repairForm1.d"></el-input>
            </el-form-item>
          </div>
          <div class="row-1">
            <el-form-item label="传真" prop="e" style="width:100%">
              <el-input v-model="repairForm1.e"></el-input>
            </el-form-item>
            <el-form-item label="电子邮件" prop="f" style="width:100%">
              <el-input v-model="repairForm1.f"></el-input>
            </el-form-item>
          </div>
          <div class="row-1">
            <el-form-item label="发票名称" prop="g" style="width:100%">
              <el-input v-model="repairForm1.g"></el-input>
            </el-form-item>
            <el-form-item label="纳税人识别号" prop="h" style="width:100%">
              <el-input v-model="repairForm1.h"></el-input>
            </el-form-item>
          </div>
          <div class="row-1">
            <el-form-item label="供货商地址" prop="i" style="width:100%">
              <el-input v-model="repairForm1.i"></el-input>
            </el-form-item>
          </div>
          <div style="padding: 0 2vw 0 0">
            <el-form-item label="备注" prop="k" style="width:100%">
              <el-input v-model="repairForm1.k" type="textarea"></el-input>
            </el-form-item>
          </div>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="primary" size="mini" @click="repairDialog1SureBtn">确定</el-button>
            <el-button type="info" size="mini" @click="repairDialog1 = false">取消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import Header from "@/components/Header";
import moment from "moment";
import LInput from "../../../components/LInput.vue";
import LButton from "../../../components/LButton.vue";

export default {
  components: {
    Header,
    LInput,
    LButton,
  },
  data() {
    return {
      name: "",

      tableData1: [
        {
          a: "100",
          b: "XXXX公司",
          c: "张三",
          d: "1331234678",
          e: "027-12341234",
          f: "123@163.com",
          g: "XXXX公司",
        },
        {
          a: "99",
          b: "XXXX公司",
          c: "张三",
          d: "1331234678",
          e: "027-12341234",
          f: "123@163.com",
          g: "XXXX公司",
        },
      ],

      repairDialog: false,
      repairForm: {
        a: "",
        b: "",
        c: "",
        d: "",
        e: "",
        f: "",
        g: "",
        h: "",
        i: "",
        j: "",
        k: "",
      },
      repairDialog1: false,
      repairForm1: {
        a: "",
        b: "",
        c: "",
        d: "",
        e: "",
        f: "",
        g: "",
        h: "",
        i: "",
        j: "",
        k: "",
      },
    };
  },
  mounted() {},
  beforeUnmount() {},
  methods: {
    //清空"新增"弹窗内容
    repairDialogClose() {
      this.$refs.repairFormRef.resetFields();
    },
    //清空“编辑”弹窗内容
    repairDialog1Close() {
      this.$refs.repairForm1Ref.resetFields();
    },
    //删除数据按钮
    del() {
      this.$confirm("此操作将永久删除该信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          // post("/airChannel/deleteAirChannel", { id: id }).then((res) => {
          //   // console.log(res);
          //   if (res.data.code == 200) {
          //     this.$message.success(res.data.data);
          //     this.getData();
          //   } else {
          //     this.$message.error(res.data.data);
          //   }
          // });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>

<style lang="less" scoped>
@import "../opera.less";

.search_bar {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.row-1 {
  display: flex;
  justify-content: space-between;
  padding: 0 2vw 0 0;
}
</style>
